Skip to content

Introducing script debugging support #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Nov 1, 2015
Merged

Conversation

daviwil
Copy link
Contributor

@daviwil daviwil commented Nov 1, 2015

This pull request introduces script debugging support in both the code .NET library and the API host process. It also includes a pretty thorough refactoring of the core library code to centralize runspace session management and improve the threading model. Many bugs have been fixed in the effort to prepare a prerelease preview, so stability is pretty good at this point.

This change introduces debugging support to both the core .NET library and
the out-of-process API host.  It adds a new DebugService class to the API
and all of the necessary messages that are specified by VS Code's
debugging protocol.

This change also marks a refactoring of runspace management logic in
the core API.  Previously the runspace used by a few different services
was interacted with directly, which complicated the process for executing
commands and scripts when the debugger was active.  A new
PowerShellSession class has been introduced to provide complete management
of the runspace(s) needed for a single editing session.  In the future,
this class will expand to support remote sessions as well.
This change redesigns the existing MessageReader and MessageWriter classes
to read/write messages using Streams instead of TextReader/TextWriter
classes.  This makes the host process compatible with VS Code's latest
debugger client so that messages sent from it can be read correctly.  It
also sets us up for being able to communicate through other types of
streams such as sockets.
This changes improves debugger variable support by allowing the
enumeration of the children of "expandable" variables (objects and
collections) and the requesting of variable scopes.  The variable scope
feature will be completed in a future commit.
In more recent VS Code builds, diagnostic message levels have been shifted
from being 1-based to 0-based.  This fix responds to that change.
The first change fixes breakpoint removal.  Previously, breakpoints were
being tracked per-file based on the script's file path.  It was discovered
that file paths were being sent through the protocol with inconsistent
casing, so path normalization was needed to ensure that breakpoints were
being indexed with the correct path casing.

The second change adds the "close" request for closing opened files.  This
request was not being used by VS Code previously but was suddenly getting
sent in newer builds of that editor.
This change fixes scenario tests that were broken by the recent message
serialization changes.  First of all, the correct stdio streams were not
being used in the test runner so no messages could be read or written.
Secondly, the existing unit tests were not using 'await' on the async
WriteMessage calls, so this was causing some trouble with their operation.

Also, some existing tests around REPL support were disabled for now until
future design changes are completed.  We're waiting on new message support
from VS Code's debug protocol.
- Send TerminatedEvent from debug service when script execution completes
- Set VariableDetails value string to space when extendable (VS Code bug)
- Add ExecutionPolicy setting for machines with higher default setting
- Add extensive logging in PowerShellSession
This change adds a new log file for the debugging service called
"DebugService.log".  This log file will be taken back out once we have the
debugging service running in the same process as the language service.
This change fixes a race condition in MessageWriter.WriteMessage where
multiple calls to the method would end up writing at the same time.  This
is due to the use of 'await' calls and happens even when both calls occur
on the same synchronization context.  The subsequent calls proceed while
the first call is awaiting the completion of I/O writes.

The solution is to use an AsyncLock to synchronize I/O operations while
allowing more messages to be queued up.
This change removes many subnamespaces that had been used in the core .NET
library for this project.  This should help with type discoverability when
a developer is using IntelliSense.  The only remaining subnamespace is
"Utility" since those classes are not essential to typical usage of the
library.

This change may be reversed in the future if sufficient feedback is
received that subnamespaces are helpful.
This change splits some small classes out into their own files for easier
location.  It also adds missing documentation for many new classes that
were added when debugging support was introduced.
This change adds missing copy right headers in all new source files.  It
also introduces a new script, AddCopyrightHeaders.ps1, that automates the
process of adding a copyright header to files which do not have one.
This changes updates the language service command completion tests to use
a file with a .psm1 extension to ensure that this file type works
correctly.
@daviwil daviwil added this to the 0.1.0 milestone Nov 1, 2015
daviwil added a commit that referenced this pull request Nov 1, 2015
Introducing script debugging support
@daviwil daviwil merged commit 746c6fa into master Nov 1, 2015
@daviwil daviwil deleted the daviwil/debug-support branch November 1, 2015 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant